package ru.stepuk.modeller.distributions;

import java.util.HashMap;
import java.util.Map;
import ru.stepuk.modeller.generators.RandomNumberGenerator;

/**
 *
 * @author ivan
 */
public class ExponentialDistribution implements Distribution {

    private double rate;
    private RandomNumberGenerator g;

    public ExponentialDistribution(double rate, RandomNumberGenerator g) {
        if (rate <= 0) {
            throw new IllegalArgumentException();
        }
        this.rate = rate;
        this.g = g;
    }

    public double nextValue() {
        return -Math.log(1 - g.nextValue()) / rate;
    }

    public Map<String, Object> getParameters() {
        Map<String, Object> res = new HashMap<String, Object>();
        res.put("Rate", rate);
        return res;
    }


}
